package com.agile.major.service.impl;

import com.agile.major.domain.BaseDictionaries;
import com.agile.major.repository.BaseDictionariesRepository;
import com.agile.major.service.BaseDictionariesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * Service Implementation for managing BaseDictionaries.
 */
@Service
@Transactional
public class BaseDictionariesServiceImpl implements BaseDictionariesService{

    private final Logger log = LoggerFactory.getLogger(BaseDictionariesServiceImpl.class);

    private final BaseDictionariesRepository baseDictionariesRepository;

    public BaseDictionariesServiceImpl(BaseDictionariesRepository baseDictionariesRepository) {
        this.baseDictionariesRepository = baseDictionariesRepository;
    }

    /**
     * Save a baseDictionaries.
     *
     * @param baseDictionaries the entity to save
     * @return the persisted entity
     */
    @Override
    public BaseDictionaries save(BaseDictionaries baseDictionaries) {
        log.debug("Request to save BaseDictionaries : {}", baseDictionaries);
        return baseDictionariesRepository.save(baseDictionaries);
    }

    /**
     *  Get all the baseDictionaries.
     *
     *  @param pageable the pagination information
     *  @return the list of entities
     */
    @Override
    @Transactional(readOnly = true)
    public Page<BaseDictionaries> findAll(Pageable pageable) {
        log.debug("Request to get all BaseDictionaries");
        return baseDictionariesRepository.findAll(pageable);
    }

    /**
     *  Get one baseDictionaries by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Override
    @Transactional(readOnly = true)
    public BaseDictionaries findOne(Long id) {
        log.debug("Request to get BaseDictionaries : {}", id);
        return baseDictionariesRepository.findOne(id);
    }

    /**
     *  Delete the  baseDictionaries by id.
     *
     *  @param id the id of the entity
     */
    @Override
    public void delete(Long id) {
        log.debug("Request to delete BaseDictionaries : {}", id);
        baseDictionariesRepository.delete(id);
    }

    @Override
    public List findByType(String type) {
        return baseDictionariesRepository.findBaseDictionariesByDicType(type);
    }
}
